package com.unit6;

import com.unit6.util.GetConnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

/**
 * @author 李琦 on 2021/8/18.
 * @version java version "16.0.1" 2021-04-20
 */
public class test5 {

        public static void main(String[] args) {
            Connection conn=null;
            Statement stmt=null;
            try{
                conn= GetConnection.getConn();//获取公共的连接对象
                String sql1="delete from stu where name='皮蛋'";//删除 皮蛋
                String sql2="update stu set sex='未知' where name ='雅雅'";//修改雅雅 性别 为 未知
                //Statement对象用来执行sql语句
                stmt=conn.createStatement();
                //执行sql
                stmt.execute(sql1);
                stmt.execute(sql2);
                System.out.println("执行成功!");
                System.out.println("执行成功");
            }catch (Exception e) {
                e.printStackTrace();
            }finally {
                try {
                    conn.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
                try {
                    stmt.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }


    }
}
